import { LoginResponse, Result, UserInfo } from '@shared/types.d';

import backendApi from '@/api/backend-api';

/**
 * 创建新用户
 * @param name 用户名
 */
export async function createUser(name: string): Promise<Result<string>> {
  return await backendApi.system.user.createUser(name);
}

/**
 * 用户登录并获取JWT token
 * @param userId 用户ID
 */
export async function login(userId: string): Promise<Result<LoginResponse>> {
  return await backendApi.system.user.login(userId);
}

/**
 * 用户登出
 */
export async function logout(userId: string): Promise<Result> {
  return await backendApi.system.user.logout(userId);
}

/**
 * 获取所有用户列表
 */
export async function getAllUsers(): Promise<Result<UserInfo[]>> {
  return await backendApi.system.user.getAllUsers();
}
